<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
    <script>
        function asb() {
            var url = "/login";
            var clientUrl = $("#clientUrl").text();
            if (clientUrl != null & clientUrl != '') {
                url += "?clientUrl=" + clientUrl;
            }
            var form = document.getElementById("form1");
            form.action = url;
            form.submit();
            // $.ajax({
            //     url: url,
            //     headers: {
            //         'Content-Type': 'application/json',
            //         'Accept': 'application/json'
            //     },
            //     data: JSON.stringify({loginName: $("#loginName").val(), password: $("#password").val()}),
            //     type: "POST",
            //     dataType: "json",
            //     success: function (data) {
            //         console.log(data);
            //     }, contentType: "json"
            // });
        }

        // $(function () {
        //     $("#sbtn").click(function () {
        //
        //         alert(11);
        //         var url = "/login";
        //         var clientUrl = $("#clientUrl").text();
        //         if (clientUrl != null & clientUrl != '') {
        //             url += "?clientUrl=" + clientUrl;
        //         }
        //         $.ajax({
        //             url: url,
        //             headers: {
        //                 'Content-Type': 'application/json',
        //                 'Accept': 'application/json'
        //             },
        //             data: JSON.stringify({loginName: $("#loginName").val(), password: $("#password").val()}),
        //             type: "POST",
        //             dataType: "json",
        //             success: function (data) {
        //                 console.log(data);
        //             }, contentType: "json"
        //         });
        //         return false;
        //     });
        //
        // });
    </script>
</head>
<body>
<span id="clientUrl" style="display: none;" th:text="${#httpServletRequest.getParameter('clientUrl')}"></span>
<form method="post" id="form1">

    用户名：<input id="loginName" name="loginName" value="tianshuo"/>
    密码 :<input id="password" type="password" name="password" value="tian1234"/>
    <br/>
    <button id="sbtn" onclick="asb();return false">提交</button>
</form>
</body>
</html>